#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    string multiply(string num1, string num2) {
        int m = num1.size();
        int n = num2.size();
        string ret(m + n, '0');
        for (int i = m - 1; i >= 0; i--)
            for (int j = n - 1; j >= 0; j--)
            {
                int tmp = (ret[i + j + 1] - '0') + (num1[i] - '0') * (num2[j] - '0');
                ret[i + j + 1] = tmp % 10 + '0';
                ret[i + j] += tmp / 10;
            }
        while (ret[0] == '0' && ret.size() > 1)
            ret = ret.substr(1, m + n - 1);
        return ret;
    }
};